/*
 * ******************************************************************************
 * Class: ServiceInterface	
 * 
 * @author: Teresa Mafalda dos Reis Frazao
 * @version:April 10, 2014 
 * 
 * The Service interface that sall be implemented by all running services. 
 * ******************************************************************************
 */
package com.feedzai.service;

import java.util.Collection;

import com.feedzai.service.data.ServiceNode;


/**
 * The Interface ServiceInterface.
 */
public interface ServiceInterface {

	/**
	 * Checks if is running.
	 *
	 * @return true, if is running
	 */
	boolean isRunning();
	
	/**
	 * Start a service thread.
	 */
	void start();
	
	/**
	 * Stops a service thread.
	 */
	void stop();

	/**
	 * Adds the is child from dependency.
	 * <p>We just add dependent services if they are not the same.
	 * Thus, a service cannot instantiate itself. 
	 *
	 * @param serviceNode the service node
	 * @return true, if successful
	 */
	boolean addIsChildFromDependency(ServiceNode serviceNode);

	/**
	 * Removes the is child from dependency.
	 *
	 * @param serviceNode the service node
	 * @return true, if successful
	 */
	boolean removeIsChildFromDependency(ServiceNode serviceNode);

	/**
	 * Adds the is parent from dependency.
	 * <p>We just add called services if they are not the same as current service.
	 *
	 * @param serviceNode the service node
	 * @return true, if successful
	 */
	boolean addIsParentFromDependency(ServiceNode serviceNode);

	/**
	 * Removes the is parent from dependency.
	 *
	 * @param serviceNode the service node
	 * @return true, if successful
	 */
	boolean removeIsParentFromDependency(ServiceNode serviceNode);

	/**
	 * Gets all the service parent nodes. 
	 * Thus, the services that are called by current service. 
	 *
	 * @return the checks if is child from dependencies
	 */
	Collection<Long> getIsChildFromDependencies();

	/**
	 * Gets the services that depend upon this service.
	 *
	 * @return the checks if is parent from dependencies
	 */
	Collection<Long> getIsParentFromDependencies();
}
